package DesignPatern.A06_代理模式.QXB.A06动态代理01;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author: Du
 * @Date: 2021/7/22 11:02
 */
public class GamePlayIH implements InvocationHandler
{
    Class cls = null;
    Object object = null;
    
    public GamePlayIH(Object obj)
    {
        this.object = obj;
    }
    
    /**
     * 实现了代理类接口的所有方法
     *
     * @param proxy
     * @param method
     * @param args
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
        if (method.getName().equalsIgnoreCase("login"))
        {
            System.out.println("代理登录");
        }
    
        if (method.getName().equalsIgnoreCase("update"))
        {
            System.out.println("代理升级");
        }
        
        Object result = method.invoke(this.object, args);//实际的方法调用
        return result;
    }
}
